(SST) ShlWAPI.pas Version 1.08

Developer Reference
(SST)ShlWAPI IsCharSpace Function
Checks if a character is a white space (e.g. a blank/space) character.
Scope
Global (i.e. this function can be called/accessed from code in any unit that includes/uses (SST)ShlWAPI.pas).
Syntax
function IsCharSpace(ach : CHAR) : BOOL;
Parameters
ach/wch [in] A single, ANSI or Unicode (multi-byte character set) character.
Return Values
The function returns a 32-bit, boolean value of type BOOL, that is TRUE (= 1) if the parameter is a white space (e.g. a blank/space) character, FALSE (= 0) if not.
Remarks
Both versions of the function returned TRUE for all white space characters with which we tested them (see example and output, further below). Specifically, the function returned TRUE for blanks/spaces, tabs, line feeds, and carriage returns. This behaviour may extend to other non-printable characters. However, this remains to be determined.
The function appears to have been first officially documented in the developer reference accompanying Microsoft SDK 6.1.
Whereas the wide character/Unicode version of the function (IsCharSpaceW), is exported by ordinal 29, in all versions in which it was documented as being supported, the ANSI version of the function (IsCharSpaceA) does not seem to be exported by a particular ordinal, if it is exported at all in ShlWAPI.dll builds, in which it is not exported by name. This results in IsCharSpaceW being available as of Windows 98 Second Edition (SE) and NT 4.0 with Internet Explorer 5.0, whereas IsCharSpaceA, having to be imported by name, can only be reliably imported as of Windows Server 2003 (ShlWAPI.dll version 6.00.3790.3959 (srv03_sp2_rtm.070216-1710).
Example
PROCEDURE TForm4.TestShlWAPIIsCharSpace(Sender : TObject); VAR testchar : CHAR; VAR testwchar : WCHAR; VAR apiretval : BOOL; //VAR i : DWORD; VAR newinfoline : STRING; BEGIN testchar := #0; testwchar := #0; apiretval := FALSE; //i := 0; newinfoline := ''; //Unicode Version testwchar := ' '; //Blank/space apiretval := IsCharSpaceW(testwchar); newinfoline := 'IsCharSpaceW called with parameter "' + testwchar + '" (#' + IntToStr(WORD(testwchar)) + ', 0x' + IntToHex(WORD(testwchar), 4) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); apiretval := FALSE; testwchar := 'A'; //Upper case "a" apiretval := IsCharSpaceW(testwchar); newinfoline := 'IsCharSpaceW called with parameter "' + testwchar + '" (#' + IntToStr(WORD(testwchar)) + ', 0x' + IntToHex(WORD(testwchar), 4) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); apiretval := FALSE; testwchar := #9; //Tab apiretval := IsCharSpaceW(testwchar); newinfoline := 'IsCharSpaceW called with parameter "' + testwchar + '" (#' + IntToStr(WORD(testwchar)) + ', 0x' + IntToHex(WORD(testwchar), 4) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); testwchar := 'B'; ////Upper case "b" apiretval := IsCharSpaceW(testwchar); newinfoline := 'IsCharSpaceW called with parameter "' + testwchar + '" (#' + IntToStr(WORD(testwchar)) + ', 0x' + IntToHex(WORD(testwchar), 4) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); apiretval := FALSE; testwchar := #10; //Line feed apiretval := IsCharSpaceW(testwchar); newinfoline := 'IsCharSpaceW called with parameter "' + testwchar + '" (#' + IntToStr(WORD(testwchar)) + ', 0x' + IntToHex(WORD(testwchar), 4) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); testwchar := '~'; //Tilde apiretval := IsCharSpaceW(testwchar); newinfoline := 'IsCharSpaceW called with parameter "' + testwchar + '" (#' + IntToStr(WORD(testwchar)) + ', 0x' + IntToHex(WORD(testwchar), 4) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); apiretval := FALSE; testwchar := #13; //Carriage return apiretval := IsCharSpaceW(testwchar); newinfoline := 'IsCharSpaceW called with parameter "' + testwchar + '" (#' + IntToStr(WORD(testwchar)) + ', 0x' + IntToHex(WORD(testwchar), 4) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); testwchar := '_'; //Underscore apiretval := IsCharSpaceW(testwchar); newinfoline := 'IsCharSpaceW called with parameter "' + testwchar + '" (#' + IntToStr(WORD(testwchar)) + ', 0x' + IntToHex(WORD(testwchar), 4) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); apiretval := FALSE; //ANSI Version testchar := ' '; //Blank/space apiretval := IsCharSpaceA(testchar); newinfoline := 'IsCharSpaceA called with parameter "' + testchar + '" (#' + IntToStr(BYTE(testchar)) + ', 0x' + IntToHex(WORD(testchar), 2) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); apiretval := FALSE; testchar := #10; //Line feed apiretval := IsCharSpaceA(testchar); newinfoline := 'IsCharSpaceA called with parameter "' + testchar + '" (#' + IntToStr(BYTE(testchar)) + ', 0x' + IntToHex(WORD(testchar), 2) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); apiretval := FALSE; testchar := '_'; //Underscore apiretval := IsCharSpaceA(testchar); newinfoline := 'IsCharSpaceA called with parameter "' + testchar + '" (#' + IntToStr(BYTE(testchar)) + ', 0x' + IntToHex(WORD(testchar), 2) + ') returned '; IF apiretval = TRUE THEN newinfoline := newinfoline + ' TRUE' ELSE newinfoline := newinfoline + ' FALSE'; Memo1.Lines.Add(newinfoline); apiretval := FALSE; Memo1.Lines.Add(''); END;
The above example will produce the following output:
IsCharSpaceW called with parameter " " (#32, 0x0020) returned TRUE IsCharSpaceW called with parameter "A" (#65, 0x0041) returned FALSE IsCharSpaceW called with parameter " " (#9, 0x0009) returned TRUE IsCharSpaceW called with parameter "B" (#66, 0x0042) returned FALSE IsCharSpaceW called with parameter " " (#10, 0x000A) returned TRUE IsCharSpaceW called with parameter "~" (#126, 0x007E) returned FALSE IsCharSpaceW called with parameter " " (#13, 0x000D) returned TRUE IsCharSpaceW called with parameter "_" (#95, 0x005F) returned FALSE IsCharSpaceA called with parameter " " (#32, 0x20) returned TRUE IsCharSpaceA called with parameter " " (#10, 0x0A) returned TRUE IsCharSpaceA called with parameter "_" (#95, 0x5F) returned FALSE
Requirements
Unit: Declared and imported in (SST)ShlWAPI.pas
Library: (SST)ShlWAPI.dcu/(SST)ShlWAPI.obj
Unicode: Implemented as ANSI (IsCharSpace and IsCharSpaceA) and Unicode (IsCharSpaceW) functions.
Min. ShlWAPI.dll version according to MS SDK doc.: 5.0
Min. ShlWAPI.dll version based on SST research: 5.0
Min. OS version(s) according to Microsoft SDK doc.: Windows 2000, Windows XP
Min. OS version(s) according to SST research.: Windows 98 SE, Windows NT 4.0 with IE 5.0, Windows 2000 and later
See Also
PathGetCharType.
 
Windows APIs: GetLastError, SetLastError


Document/Contents version 1.00
Page/URI last updated on 07.12.2023
 
Copyright © Stoelzel Software Technologie (SST) 2010 - 2015
Suggestions and comments mail to:
webmaster@stoelzelsoftwaretech.com